//
//  Thirdlub_routeTableViewCell.m
//  Project_B
//
//  Created by dllo on 15/11/26.
//  Copyright © 2015年 张闯. All rights reserved.
//

#import "Thirdlub_routeTableViewCell.h"

#define CWIDTH self.contentView.frame.size.width
#define CHEIGHT self.contentView.frame.size.height

@interface Thirdlub_routeTableViewCell ()
@property (nonatomic, retain) UIView *whiteView;
@property (nonatomic, retain) UIView *layerView;
@property (nonatomic, retain) UIView *leyerView;
@property (nonatomic, retain) CAGradientLayer *gradientLayer;
@end

@implementation Thirdlub_routeTableViewCell

#pragma mark - 初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.image = [[UIImageView alloc] init];
        [self.contentView addSubview:self.image];
        self.image.userInteractionEnabled = YES;
        
        self.layerView = [[UIView alloc] init];
        self.gradientLayer = [CAGradientLayer layer];
        self.gradientLayer.colors = [NSArray arrayWithObjects:(id)[UIColor grayColor].CGColor,(id)[UIColor clearColor].CGColor, nil];
        self.gradientLayer.startPoint = CGPointMake(0.01, 0.01);
        self.gradientLayer.endPoint = CGPointMake(0.03, 0.3);
        [self.layerView.layer insertSublayer:self.gradientLayer atIndex:0];
        [self.contentView addSubview:self.layerView];
        
        self.leyerView = [[UIView alloc] init];
        [self.contentView addSubview:self.leyerView];
        self.leyerView.backgroundColor = [UIColor blackColor];
        self.leyerView.alpha = 0.3;
        
        self.times = [[UILabel alloc] init];
        [self.contentView addSubview:self.times];
        
        self.catename = [[UILabel alloc] init];
        [self.contentView addSubview:self.catename];
        
        self.whiteView = [[UIView alloc] init];
        [self.contentView addSubview:self.whiteView];
        
        self.title = [[UILabel alloc] init];
        [self.contentView addSubview:self.title];
        
    }
    return self;
}
#pragma mark - 布局
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.image.frame = CGRectMake(5, 5, CWIDTH - 10, CHEIGHT - 10);
    self.image.contentMode = UIViewContentModeScaleAspectFill;
    self.image.layer.cornerRadius = 5;
    self.image.clipsToBounds = YES;
    
    self.layerView.frame = self.image.frame;
    self.gradientLayer.bounds = self.layerView.bounds;
    self.gradientLayer.frame = self.layerView.bounds;
    
    self.leyerView.frame = self.image.frame;
    
    self.times.frame = CGRectMake(self.image.frame.origin.x + 10, self.image.frame.origin.y + 10, 250, 12);
    self.times.font = [UIFont fontWithName:@"Helvetica-Bold" size:12];
    self.times.textColor = [UIColor whiteColor];
    
    self.catename.frame = CGRectMake(self.times.frame.origin.x, self.times.frame.origin.y + self.times.frame.size.height + 10, 100, 12);
    self.catename.font = [UIFont fontWithName:@"Helvetica-Bold" size:12];
    self.catename.textColor = [UIColor whiteColor];
    
    self.whiteView.frame = CGRectMake(5, self.image.frame.size.height - 50 + 10, self.image.frame.size.width, 45);

    self.title.frame = CGRectMake(self.whiteView.frame.origin.x + 10, self.whiteView.frame.origin.y + 10, self.whiteView.frame.size.width - 65, 14);
    self.title.font = [UIFont fontWithName:@"Helvetica" size:14];
    self.title.numberOfLines = 0;
    [self.title sizeToFit];
    self.title.textColor = [UIColor whiteColor];
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
